package com.tuo51.evaluate.service.appuser;

import com.tuo51.evaluate.domain.appusers.Vip;
import com.tuo51.evaluate.repositories.appusers.VipRepository;
import com.tuo51.foudation.constant.APPConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class VipService {

    @Autowired
    VipRepository vipRepository;

    public List<Vip> getAllVipWithoutHidden(){
        Vip vip = new Vip();
        vip.setStatus(APPConstants.Status.NOW_ONLINE.getValue());
        vip.setHidden(false);

        return vipRepository.findAll(Example.of(vip), Sort.by(Sort.Direction.DESC,"level"));
    }

    public Page<Vip> getAllVip(Pageable pageable){
        return vipRepository.findAllByOrderByTypeAscPriceDescValueDesc(pageable);
    }

}
